home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 27 / Commodore_Free_Issue_27_2009_Commodore_Computer_Club.d64 / vic ram < prev    next >
Text File  |  2023-02-26  |  7KB  |  272 lines

  1. ..
  2.  
  3.  
  4. Understanding VIC-20 Ram Expansion
  5.  
  6. One of the most confusing things about
  7. the VIC-20 is the screwy way that
  8. memory locations shift around when you
  9. add RAM expansion. Add 8K of RAM or
  10. more & everything changes: suddenly
  11. Screen & Colour Memory move to
  12. different locations. Old programs for
  13. the unexpanded VIC that POKE to the
  14. screen or use redefined character
  15. graphics no longer work. Depending on
  16. the amount of RAM expansion you have,
  17. BASIC even begins in different
  18. locations. Aargh!
  19.  
  20. The diagrams on this page all come
  21. from Leif Bloomquist's C= VIC-20
  22. Memory Blocks Illustrated. (See VIC20
  23. MEMORY article on this disk)
  24.  
  25. http://8bitcentral.com/files/
  26.  vicmemory.pdf
  27.  
  28. This PDF helped me a lot in my quest
  29. to figure all this out. Click HERE
  30.  
  31. http://home.ica.net/{$de}leifb/
  32.  commodore/index.htm
  33.  
  34. to visit Leif's site.
  35.  
  36. Also, Anders Persson has written a
  37. great tutorial:
  38.  
  39. http://user.tninet.se/{$de}pug510w/
  40.  datormuseum/expandedvic20.html
  41.  
  42. (ED Reproduced in this issue of
  43. C= FREE) Graphics & Bigger Screen in
  44. BASIC on the Expanded VIC-20. Anders'
  45. website is HERE.
  46.  
  47. Another good resource is the book VIC
  48. Revealed, by Nick Hampshire. If you
  49. want to really understand how the VIC
  50. works, you owe it to yourself to get
  51. this book. It's fairly common, you can
  52. often find it on eBay.
  53.  
  54. http://www.ebay.com/
  55.  
  56. Like most things, it doesn't seem that
  57. hard once you figure it all out ...
  58.  
  59. FIGURING IT ALL OUT
  60.  
  61.  DEC    HEX   BLOCK
  62.  -------------------
  63.  57344  E000  Block7
  64.  49152  C000  Block6
  65.  40960  A000  Block5
  66.  32768  8000  Block4
  67.  24576  6000  Block3
  68.  16384  4000  Block2
  69.  8192   2000  Block1
  70.   0     0000  Block0
  71.  -------------------
  72.  
  73. Let's imagine the VIC's memory as a
  74. series of 8K "blocks," starting at
  75. 0000 (block 0) & ending with block 7
  76. (E000). Expansion RAM can be placed in
  77. blocks: 1,2,3 & 5. There's also a
  78. little 3K slice available in block 0
  79. that we'll talk about later.
  80.  
  81. If you put 8K in blocks 1,2,& 3 your
  82. VIC will have 29K total RAM available
  83. to BASIC. That's the 5K the VIC came
  84. with plus 8K in blocks 1,2 & 3. RAM
  85. has to be contiguous to be seen by
  86. BASIC.  That is, BASIC only sees RAM
  87. as a single big chunk of memory. Since
  88. blocks 1 - 3 are right next to each
  89. other, the VIC can see all of it as
  90. one big 24K hunk of RAM. So, looking
  91. at the diagram, you can understand why
  92. 24K is the maximum amount of RAM
  93. expansion available to BASIC.
  94.  
  95. BLOCK 5
  96.  
  97. You've no doubt observed that block 5
  98. is not contiguous with blocks 1,2,& 3.
  99. Block 4 is in the way. So BASIC can't
  100. see RAM in block 5.  You might be
  101. asking yourself: If RAM in block 5 is
  102. invisible to BASIC, what good is it?
  103.  
  104. You can place machine language
  105. programs in block 5, or use the RAM to
  106. store data that can be read with
  107. BASIC's PEEK statement. So, RAM in
  108. block 5 can still be quite useful. The
  109. only thing you can't use it for is to
  110. add to the RAM available for BASIC
  111. programs.
  112.  
  113. Another feature of block 5 is that
  114. programs stored in this area can be
  115. "auto-started" when the VIC is reset.
  116. Most cartridge games are located in
  117. block 5. You can tell because these
  118. games start automatically when you
  119. turn the VIC on. To further illustrate
  120. the Programmers' Aid Cartridge puts
  121. its program in block 3. That explains
  122. why you have to enter SYS 28681 to
  123. launch the Programmers' Aid. Only
  124. programs located in block 5 will start
  125. automatically when you reset the VIC.
  126.  
  127. It sounds pretty straight forward,
  128. doesn't it? Can it really be this
  129. simple? Unfortunately, the answer is
  130. No.  We're going to have to take a
  131. look at what's in block 0 & block 4 to
  132. see where things get a little tricky.
  133.  
  134.  
  135. BLOCK 0
  136.  
  137. DEC   HEX  BLOCK
  138. -----------------
  139. 57344 E000 BLOCK7
  140. 49152 C000 BLOCK6      38912 9800  I/O
  141. 40960 A000 BLOCK5      38400 9600 Scn
  142.                              Color mem
  143. 32768 8000 BLOCK4 ---> 37800 9400 ---
  144. 24576 6000 BLOCK3      36864 9000
  145.                                VIC/VIA
  146. 16384 4000 BLOCK2      32968 8000 Char
  147.                                    ROM
  148. 8192  2000 BLOCK1
  149. 0000  0000 BLOCK0 ---> 7680 1E00 Scn
  150.                                 memory
  151.               4608 1200  User BASIC
  152.               4696 1000   "    "
  153.               1024 0400  3k Available
  154.               0000 0000  Basic working
  155.                                 Memory
  156.  
  157. The diagram above blows up blocks 0 &
  158. 4 so we can see their contents. Take a
  159. close look at block 0 on the unex-
  160. panded VIC. The area, from 1000 to
  161. 1DFF, is User BASIC Area. This is RAM
  162. that's available for BASIC programs.
  163. This one tiny little slice of block 0
  164. is all the RAM we have to work with.
  165. Not much, is it?  Let's start adding
  166. some RAM & see what happens.
  167.  
  168. ADDING 3K
  169.  
  170. The section from 0400 to 0FFF in our
  171. block 0 diagram is a 3K area set aside
  172. for RAM expansion. This is where the
  173. RAM in Commodore's 3K RAM Expansion
  174. cartridge or 3K Super Expander goes.
  175. After adding one of these cartridges
  176. our block 0 diagram looks like this:
  177.  
  178. ------------------------------
  179. 7680 1E00 Screen mem
  180. ------------------------------
  181. 4608 1200 User BASIC area
  182. ---------
  183. 4696 1000  "     "     "
  184. ---------
  185. 1024 0400  "     "     "
  186. ------------------------------
  187.  0   0000 BASIC working Memory
  188. ------------------------------
  189.  
  190. And there we have it-- The beginning
  191. of BASIC moves down to 0400 & we now
  192. have an extra 3K of RAM to work with.
  193. Now let's add an 8K RAM cartridge to
  194. block 1.
  195.  
  196.             BLOCK 1
  197.   8k RAM CARTRIDGE INSTALLED
  198.  
  199. 8192 2000
  200. ------------------------------
  201. 7680 1E00 Screen memory
  202. ------------------------------
  203. 4608 1200 User BAsic area
  204. ---------
  205. 1024 0400  "     "     "
  206. ------------------------------
  207. 0000 0000 BASIC working memory
  208. ------------------------------
  209.  
  210. The diagram above represents our VIC
  211. with 3K expansion, plus 8K in block 1.
  212. Uh oh, there's a problem. Do you see
  213. it?  Remember, all RAM available to
  214. BASIC must be in a single continuous
  215. chunk.  Screen Memory (1E00 - 1FFF) is
  216. separating the User BASIC Area from
  217. the 8K expansion we want to put in
  218. block 1.  What do we do?  There's only
  219. one thing we can do: we have to move
  220. Screen Memory somewhere else.  The VIC
  221. does this automatically when you add
  222. expansion RAM to block 1.  Here's what
  223. block 0 & 1 look like after adding 8K
  224. to block 1.
  225.  
  226.             BLOCK 1
  227.   8k RAM CARTRIDGE INSTALLED
  228.  
  229. 8192 2000
  230. ------------------------------
  231. 7680 1E00 User BASIC Area
  232. 4608 1200  "     "     "
  233. ------------------------------
  234. 4096 1000 Screen Memory
  235. ------------------------------
  236. 1024 0400   3K Available
  237. ------------------------------
  238.  0   0000 BASIC Working Memory
  239. ------------------------------
  240.  
  241.  
  242. Screen Memory moves from 1E00 to 1000.
  243. Now we can add 8K to blocks 1,2,& 3 &
  244. all the BASIC RAM will be in one
  245. continuous chunk.  BASIC now begins at
  246. 1200 & runs until the end of expansion
  247. RAM.  One more detail: Colour Memory
  248. in block 4 has to be a precise
  249. distance from Screen Memory. Since we
  250. moved Screen Memory, Colour Memory
  251. will have to move too-- from 9600 down
  252. to 9400.
  253.  
  254. Hey, what about my 3K RAM at 0400?
  255. Since Screen Memory is now separating
  256. our 3K area from the User Basic Area,
  257. RAM in the 3K area becomes invisible
  258. to BASIC just like RAM in block 5.
  259. It's a trade-off, but it allows us to
  260. fill blocks 1 - 3 with RAM that can be
  261. used by BASIC.
  262.  
  263. The next article on this disk "VIC20
  264. MEMORY" ties it all together with a
  265. diagram showing all the possible
  266. memory configurations. Note how Screen
  267. Memory (block 0) & Colour Memory
  268. (block 4) move to different locations
  269. when adding 8K+ of RAM expansion.
  270.  
  271. ..end..
  272.